package cn.yh.nft.turbo.order.domain.listener.config;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

import java.util.concurrent.*;

/**
 * @ClassName: OrderListenerConfig
 * @Author: 草莓爱上啵啵
 */
@Configuration
@EnableAsync
public class OrderListenerConfig {

    @Bean("orderListenExecutor")
    public Executor orderListenExecutor(){

        ThreadFactory nameThreadFactory = new ThreadFactoryBuilder()
                .setNameFormat("orderListener-%d").build();

        return new ThreadPoolExecutor(10, 20,
                0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>(1024), nameThreadFactory, new ThreadPoolExecutor.AbortPolicy());
    }
}
